<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript" src="/assets/libs/fastadmin-layer/dist/layer.js"></script>
<style>
    iframe {
        border-width: 0px;

    }
</style>
<script>
    function coup_add(id){
        var cid="{$cid}";
        $.ajax({
            type: "post",
            url: "/admin/coupon/coupon_save",
            data: {"id":id,"cid":cid},
            dataType: "json",
            success: function(data){
                var url="/admin/coupon/coupon_product_list?cid={$cid}";
                if(data=='1'){
                    $("#c_p_select").attr("src",url)
                }else if(data=='2'){
                    //alert("添加失败");
                    layer.msg("添加失败");
                }else if(data=='3'){
                    //alert("数据已存在");
                    layer.msg("数据已存在");
                }else{
                    ///alert("商品ID不存在");
                    layer.msg("商品ID不存在");

                }
            }
        });
    }

    function sing_add(){
        var id=$("#number").val();
        var dd="{$cid}";
        $.ajax({
            type: "post",
            url: "/admin/coupon/coupon_save",
            data: {"id":id,"cid":dd},
            dataType: "json",
            success: function(data){
                if(data=='1'){
                    window.location.href="/admin/coupon/coupon_product?cid={$cid}"
                }else if(data=='2'){
                    alert("添加失败");
                }else if(data=='3'){
                    alert("数据已存在");
                }else{
                    alert("商品ID不存在");
                }
            }
        });



    }
</script>
<div class="content">
    <div class="panel panel-default panel-intro">
        <div class="panel-body">
            <div id="" class="tab-content">
                <div class="tab-pane fade active in" id="one">
                    <div class="widget-body no-padding">
                        <div class="bootstrap-table">
                            <div class="fixed-table-toolbar">
                                <div class="bs-bars pull-left" style="width:100%;">
                                    <div id="toolbar" class="toolbar" style="position: relative;">
                                        产品ID:<input type="text" style="width:160px;height:36px;line-height:36px;border:1px solid #ccc;padding-left:5px;" id="number">
                                        <a href="javascript:void;" class="btn btn-success btn-add " title="添加" id="zdy_product"  onclick="sing_add();">
                                            <i class="fa fa-plus"></i> 添加
                                        </a>
                                    </div>
                                </div>
                                <div>
                                    <div style="width:47%;float:left;">
                                        <table  class="table table-striped table-bordered table-hover table-nowrap" data-operate-edit="1">
                                            <thead>
                                            <tr>
                                                <th class="bs-checkbox " style="text-align: center; vertical-align: middle;width:10%;height: 45px;" data-field="0">ID</th>
                                                <th style="text-align: center; vertical-align: middle;width:80%;" data-field="id"><div class="th-inner ">可选产品</div><div class="fht-cell"></div></th>
                                                <th style="text-align: center; vertical-align: middle;width:10%;" data-field="id"><div class="th-inner ">操作</div><div class="fht-cell"></div></th>
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody data-listidx="0">
                                            {volist name="listPrc" id="vo"}
                                            <tr data-index="0">
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.id}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.s_name}</td>
                                                <td style="text-align: center; vertical-align: middle; ">
                                                    <span class="btn btn-success btn-add add_product"  onclick="coup_add({$vo.id});" >添加</span>
                                                </td>
                                            </tr>
                                            {/volist}
                                            </tbody>
                                        </table>
                                    </div>
                                    <div style="width:47%;float:right;">
                                        <iframe id="c_p_select"   height="1000px"; width="100%"  border="0"src="/admin/coupon/coupon_product_list?cid={$cid}">

                                        </iframe>
                                    </div>
                                    <div style="clear:both"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>